﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AntMovement.Comm.Helper
{
    public class BytesHelper
    {
        public static int BytesToInt(byte hh, byte hl, byte lh, byte ll) => (hh << 24) + (hl << 16) + (lh << 8) + ll;

        /// <summary>
        /// 未注册
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static byte[] ToUnregistered(byte cmd) => new byte[] { 3, 0, 2, 0, cmd };

        /// <summary>
        /// 未知异常
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static byte[] ToUnknown(byte cmd) => new byte[] { 3, 0, 255, 0, cmd };

        /// <summary>
        /// 不存在标签
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static byte[] ToNoLabel(byte cmd) => new byte[] { 3, 0, 3, 0, cmd };

        /// <summary>
        /// 解析标签异常
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static byte[] ToParseTagException(byte cmd) => new byte[] { 3, 0, 5, 0, cmd };

        /// <summary>
        /// 解析值异常
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        public static byte[] ToAnalyticValueAnomaly(byte cmd) => new byte[] { 3, 0, 8, 0, cmd };
    }
}
